// memset模拟实现

#include <iostream>
#include <assert.h>

void* memset_self(void* ptr, int value, size_t num)
{
    assert(ptr);
    void* start = ptr;
    while(num--)
    {
        *(char*)ptr = value;
        ptr = (char*)ptr + 1;
    }
    return start;
}

int main()
{
    int arr[10] = {1,2,3,4,5,6,7,8,9,10};
    memset_self(arr, 1, 10);
    for(int i = 0; i < sizeof(arr) / sizeof(int); ++i)
    {
        std::cout << arr[i] << " ";
    }
    std::cout << std::endl;
    return 0;
}
